use salvo::{__private::tracing::info, Listener, Router, Server, conn::TcpListener, handler};

use crate::model::result::R;

pub mod model;

// Handler for English greeting
#[handler]
async fn hello() -> R<&'static str> {
    R::ok("hello world!")
}

// Handler for Chinese greeting

#[tokio::main]
async fn main() {
    // 初始化日志
    tracing_subscriber::fmt::init();
    info!("开始运行.....");
    // 绑定端口为9000
    let acceptor = TcpListener::new("0.0.0.0:9000").bind().await;

    info!("绑定端口号为9000....");

    let router = Router::new().get(hello);

    // Print router structure for debugging
    println!("{:?}", router);

    // Start serving requests
    Server::new(acceptor).serve(router).await;
}
